Creating a ClientProtector COM Event Sink

SoftwareShield ClientProtector COM Component > Controlling Your Application With The ClientProtector > Creating a ClientProtector COM Event Sink

## Creating a ClientProtector COM Event Sink

A COM event sink is the "receiving end" of an event source. In this case, the event source is the ClientProtector and the sink will be some part of your application. During the scope of a function call to the ClientProtector (before it returns), one or more events may be fired, depending on a variety of conditions. When an event is fired, control is passed synchronously back to your application, directly to the appropriate event handler.

By connecting your application to the ClientProtector as a sink, your event handler function will receive a synchronous call when the event occurs, allowing you to prompt the user to take some action (or to have your application take some intermediate silent action).

Parameters will be passed to your event handler where necessary, allowing your application to have the information it needs immediately available. In turn, when your application event handler is finished its work and returns, you will pass back information the ClientProtector needs in reference parameters.

In general, the event handlers for the ClientProtector are designed to fire only when the ClientProtector needs information from the "outside world"; in particular, the user.

By interacting with the user only through your application, you have complete control over the user interface that is presented. It can be in any form you wish and in any language. The ClientProtector will never "speak" directly to the user with a visual component or dialog. It will only ever do this indirectly through event handlers you connect.

The events published by the ClientProtector through its IDispatch interface are:

- OnAttemptDeactivate

- OnAttemptRecover

- OnAttemptReleaseCP

- OnMissingLicenseFile

- OnPrepareAutoActivate

- OnAttemptCheckInCopyProtection

- OnAutoActivateResult

The majority of the information you need to create the COM event sinks is contained in the sections on Linking To ClientProtector In Your Application.

### Events are non-reentrant

Functions that cause an event to be fired are not reentrant. This means that you should never call a function on the ClientProtector from inside the event handler. Doing so may cause a stack overflow by infinite recursion.